package sharping.appilog.Adapter;

import java.util.ArrayList;

import sharping.appilog.R;
import sharping.appilog.DataTree.CouponData;
import sharping.appilog.ListItem.CouponItem;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

public class RCuponAdapter extends BaseAdapter {

	Context context;
	ArrayList<CouponData> items;
	LayoutInflater inflater;
	int Type;
	
	public RCuponAdapter(Context context, ArrayList<CouponData> items, LayoutInflater inflater, int Type) {
		this.context = context;
		this.items = items;
		this.inflater = inflater;
		this.Type = Type;
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return items.size();
	}

	@Override
	public CouponData getItem(int position) {
		// TODO Auto-generated method stub
		return items.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		CouponItem v;
		
		if (convertView == null) {
			
			int[] viewId = {
				R.id.list_coupon_type,
				R.id.list_coupon_bizname,
				R.id.list_coupon_date,
				R.id.list_coupon_discount
			};
			
			convertView = inflater.inflate(R.layout.list_coupon_type1, null);
			
			v = new CouponItem(context, convertView, viewId);
			
			convertView.setTag(v);
		} else {
			v = (CouponItem) convertView.getTag();
		}
		v.setItem(items.get(position));
		v.setParam();
		return convertView;
	}

}
